package kuzha.runtime;

public class KzFloat64 extends KzFloat {
	public static KzFloat64 valueOf(double num) {
		return new KzFloat64(num);
	}
	
	public final double value;
	
	protected KzFloat64(double value) {
		this.value = value;
	}
	
	@Override
	public boolean isTrue() {
		return value != 0;
	}
	
	@Override
	public Object toJavaObject() {
		return value;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(value);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final KzFloat64 other = (KzFloat64) obj;
		if (Double.doubleToLongBits(value) != Double
				.doubleToLongBits(other.value))
			return false;
		return true;
	}
	
	@Override
	public Number getNumber() { return value; }
	@Override
	public String toString() { 	return Double.toString(value); }
	@Override
	public String toHexString() { return Double.toHexString(value); }
	
}
